<#include '/admin/header.html' >
<div class="admin-main">
	<div class="shadowBoxWhite  whiteBox"
		style="padding: 10px 0 10px 10px;">
		<form method="post" class="layui-form layui-form-pane" action="" id="sendForm">
			<label>发放数量：</label> 
				<input type="text" name="createnum" class="input_text easyui-numberbox" maxlength="4" data-options="required:true" style="ime-mode:disabled" onkeydown="if(event.keyCode==13)event.keyCode=9" onkeypress="if ((event.keyCode<48 || event.keyCode>57)) event.returnValue=false"/> 
				<input type="hidden" name="typeid" maxlength="4" value="${typeid}" />
				
			     <button class="layui-btn layui-btn-mini" type="submit"lay-submit="" lay-filter="submitForm">确认发放</button>
		</form>
	</div>
</div>
<script>
var index = parent.layer.getFrameIndex(window.name);

layui.use(['form', 'layedit', 'laydate'], function(){
    var form = layui.form()
        ,layer = layui.layer
        ,layedit = layui.layedit
        ,laydate = layui.laydate;
    //发放
	form.on('submit(submitForm)', function(data){
		var val=$("input[name='createnum']").val();
		if(val==""){
			alert("请填写 发行量");
			return ;
		}
		if(val>="50"){
			layer.open({
				  title: ''
				  ,content:"正在发放,请耐心等候！！！"
					,time: 3000
				});
		}
		if(isNaN(val)){
			alert("请填写正确数字!");
			return ;
		}
    	var options = {
   			url:ctx+"/shop/admin/bonus/send-for-off-line.do?ajax=yes",
   			type:"post",
   			dataType:"json",
   			success:function(res){
   				if (res.result == 1) {
   					$.Loading.success("成功发放[" + res.count + "]个红包");
				} else {
					$.Loading.error(res.message);
				}
   			}
   		};
   		$("#sendForm").ajaxSubmit(options);
       return false;
    });

});
    
	
</script>
<#include '/admin/footer.html' >
